<?php
session_start();
include 'connect.php';

$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);

$password = md5($_POST['password']);


$sql = "select * from members where Username = '$username' and Password = '$password'";
$result = mysql_query($sql, $connection);
$numResults = mysql_num_rows ($result);
$row = mysql_fetch_assoc ($result);
if (!$result) { die('Error: ' . mysql_error() . 'in query '.$sql); }

if ($numResults == 1)
 {
    $_SESSION['Username'] = $row["Username"];
    $_SESSION['MemberID'] = $row["MemberID"];
    
    header ('location: welcome.php');
    
 }
 else
 	echo "We seemed to have trouble loggin you in, $username try to <a href='index.php'>login</a> again and see if we get it.";
 	
 mysql_close($connection);
?>

</div>
</body>
</html>

 
 